package com.rd.student.ruanjian.class4.zhouzihe.day0731;

import java.util.ArrayList;
import java.util.Arrays;


public class TestRandom1 {
    public static void main(String[] args) {
        int[] arr = new int[50];
        for (int i = 0; i < 50; i++) {
            arr[i] = i;
        }
        System.out.println(Arrays.toString(arr));
        ArrayList<Integer> eleList = new ArrayList<>(20);
        while (eleList.size() < 20) {
            int random = (int) (Math.random() * 50);
            int ele = arr[random];
            if (!eleList.contains(ele)) {
                eleList.add(ele);
                System.out.println("添加元素:" + ele);
            } else {
                System.out.println("重复元素:" + ele);
            }
        }
    }
}
